package com.openbravo.data.loader;

import com.openbravo.basic.BasicException;

import java.sql.SQLException;

public abstract class Transaction<T>
{
  private Session s;

  public Transaction(Session paramSession)
  {
    this.s = paramSession;
  }

  public final T execute()
    throws BasicException
  {
    if (this.s.isTransaction())
      return transact();
    try
    {
      this.s.begin();
      Object localObject = transact();
      this.s.commit();
      return (T) localObject;
    }
    catch (BasicException localBasicException)
    {
      try {
		this.s.rollback();
	} catch (SQLException e) {
		// TODO Auto-generated catch block
		e.printStackTrace();
		throw new RuntimeException(e);//ati
	}
      throw localBasicException;
    }
    catch (SQLException localSQLException)
    {    throw new BasicException("Transaction error", localSQLException);
    }

  }

  protected abstract T transact()
    throws BasicException;
}

/* Location:           D:\PowerFulPOS-2.30.2\openbravopos.jar
 * Qualified Name:     com.openbravo.data.loader.Transaction
 * JD-Core Version:    0.6.0
 */